﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>init main(install)</title>
		<script type="text/ecmascript" src="/accHestia/lib/jqgrid/js/jquery.min.js"></script>
        
        
        <script src="/accHestia/lib/jquery_ui/1.12.1/jquery-ui.js"></script>
        <link rel="stylesheet" type="text/css" media="screen" href="/accHestia/lib/jquery_ui/1.12.1/jquery-ui.css" />
        
		
		<style type="text/css">
			.classred {
				background-color:yellow;
				color:red;
			}
			
			.install_guide {
				width:200px;
				margin: 10px 0 0 0;
				padding: 10px;
				border: 0;
				border: 1px dotted #785;
				background: #f5f5f5;
			}
		</style>
		<script src="/accHestia/src/view/js/md5.js"></script>
        <script src="/accHestia/src/view/js/rpc.js"></script>

		<script>
            function confirm_conn_callback(ps_data) {
                if ("OK" == ps_data["result"]) {
                    //$("#for_debug").html("恭喜,数据库连接成功\n点击[确定]进入下一项配置.");
                    $("#form_step1").fadeOut(600,  function() {$("#form_step2").fadeIn(600);});
                } else {
                    $("#for_debug").html(data + "数据库连接失败:\n");
                }
            }
			function on_confirm_mysql_conn_click(e) {
				e.preventDefault();//必加,不然form中的button默认不post?
                call_rpc("confirm_mysql_conn", {}, confirm_conn_callback);
			}
            
            function rebuild_acc_db_callback(ps_data) {
                if ("OK" == ps_data["result"]) {
                    //$("#for_debug").html("恭喜,数据库重建成功\n点击[确定]进入下一项配置.");
                    $("#form_step3").slideDown(300, function(){$("#form_step2").slideUp(700);});
                } else {
                    $("#for_debug").html(data + "重建数据库失败!");
                }
            }
			
			function on_rebuild_acc_db_click(e) {
				e.preventDefault();
                call_rpc("rebuild_acc_db", {}, rebuild_acc_db_callback);
			}

            function set_adm_pwd_callback(ps_data) {
                if ("OK" == ps_data["result"]) {
                    //$("#for_debug").html("数据库各种表创建成功,并成功插入了一些乱七八糟的数据..");
                    $("#form_step3").slideUp(300, function(){$("#form_step4").slideDown(700);});
                } else {
                    $("#for_debug").html(data + "重建各种表失败!\n");
                }
            }
			function on_set_admin_pwd_click(e) {
				e.preventDefault();
				
				//密码<->重复密码核对
				if ($("#i_pwd_new").val() != $("#i_repwd").val()) {
					alert("两次输入的密码不相同!");
					return;
				}
				
                call_rpc("set_admin_pwd", {
                        admPwd:hex_md5($("#i_pwd_new").val()), 
                        admEmail:$("#i_email").val(),
                        admName:$("#i_adm_name").val(),
                    }, 
                    set_adm_pwd_callback);
			}

            function set_acc_category_callback(ps_data) {
                if ("OK" == ps_data["result"]) {
                    <?php $test_mode = true; ?>
                    <?php if($test_mode) { ?>
                        if(confirm("预设会计行业:" + $("#select_categroy").val() + "成功!\n是否添加初始测试数据?")) {
                            window.location.href = "/accHestia/src/view/feature/init/genUser.php";
                        } else {
                            window.location.href = "/accHestia/";
                        }
                    <?php } else { ?>
                        alert("预设会计行业:" + $("#select_categroy").val() +"成功!\n点击[确定]以完成服务器配置过程.");
                        window.location.href = "/accHestia/";
                    <?php } ?>
                } else {
                    alert("预设会计行业:" + $("#select_categroy").val() + "失败!\n" + data);
                }
            }
			function on_set_acc_category(e) {
				e.preventDefault();
                call_rpc("set_acc_category", {cate:$("#select_categroy").val(),}, set_acc_category_callback);
			}
			
			function set_guide_center() {
				$(".guide").css("margin-top", ($(window).height() - $(".guide").height() ) / 2) ;
				$(".guide").css("margin-left", ($(window).width() - $(".install_guide").width() ) / 2) ;
			}
		</script>

		<script type="text/javascript">
			$(document).ready(function(){
				set_guide_center();
				$(window).resize(function() {
					set_guide_center();
				});
				
				$("#confirm_mysql_conn_ok").bind("click", on_confirm_mysql_conn_click);
				$("#rebuild_acc_db").bind("click", on_rebuild_acc_db_click);
				$("#set_admin_pwd").bind("click", on_set_admin_pwd_click);
				$("#set_acc_category").bind("click", on_set_acc_category);
				//$("#config_done").bind("click", on_config_done_click);


                //$( "#tabs" ).tabs().addClass( "ui-tabs-vertical ui-helper-clearfix" );
                //$( "#tabs li" ).removeClass( "ui-corner-top" ).addClass( "ui-corner-left" );
				
			});

		</script> 
        
  <style>
  .ui-tabs-vertical { width: 55em; }
  .ui-tabs-vertical .ui-tabs-nav { padding: .2em .1em .2em .2em; float: left; width: 12em; }
  .ui-tabs-vertical .ui-tabs-nav li { clear: left; width: 100%; border-bottom-width: 1px !important; border-right-width: 0 !important; margin: 0 -1px .2em 0; }
  .ui-tabs-vertical .ui-tabs-nav li a { display:block; }
  .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 1px; }
  .ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: right; width: 40em;}
  </style>

    </head>
    <body>
<!--div id="tabs">
  <ul>
    <li><a href="#tabs-1">Nunc tincidunt</a></li>
    <li><a href="#tabs-2">Proin dolor</a></li>
    <li><a href="#tabs-3">Aenean lacinia</a></li>
  </ul>
  <div id="tabs-1">
    <h2>Content heading 1</h2>
    <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
  </div>
  <div id="tabs-2">
    <h2>Content heading 2</h2>
    <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
  </div>
  <div id="tabs-3">
    <h2>Content heading 3</h2>
    <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
    <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
  </div>
</div-->

		<div class="guide">
			<form id="form_step1">
			  <fieldset class="install_guide">
				<legend>Step1</legend>
				确认mysql连接OK.
				<button id="confirm_mysql_conn_ok">点击确认</button>
			  </fieldset>
			</form>
			
			<form id="form_step2" style="display:none; ">
			  <fieldset class="install_guide">
				<legend>Step2</legend>
				重建acc_db数据库. <button id="rebuild_acc_db">点击重建</button>
			  </fieldset>
			</form>
			
			<form id="form_step3" style="display:none; ">
			  <fieldset class="install_guide">
				<legend>Step3</legend>
				重置管理员密码及邮箱. </br>
				<label for="i_admin">预设帐号</label>
				<input type="text" id="i_admin" disabled="disabled" value="admin"/></br>
				<label for="i_pwd_new">初始密码</label>
				<input type="password" id="i_pwd_new"/></br>
				<label for="i_repwd">重复密码</label>
				<input type="password" id="i_repwd"/></br>
				<label for="i_adm_name">姓名</label>
				<input type="text" id="i_adm_name"/></br>
				<label for="i_email">email</label>
				<input type="text" id="i_email"/></br>
				<button id="set_admin_pwd">点击设置管理员信息</button>
			  </fieldset>
			</form>
			
			<form id="form_step4" style="display:none;">
			  <fieldset class="install_guide">
				<legend>Step4</legend>
				选择应用行业(预设会计科目不同). 
				<select id="select_categroy">
				<option value="外商投资">外商投资</option>
				<option value="铁路运输">铁路运输</option>
				<option value="房地产">房地产</option>
				<option value="行政单位">行政单位</option>
				<option value="保险业">保险业</option>
				<option value="金融业">金融业</option>
				<option value="医院">医院</option>
				<option value="中小学">中小学</option>
				<option value="普通事业">普通事业</option>
				<option value="股份制">股份制</option>
				<option value="农业">农业</option>
				<option value="邮电业">邮电业</option>
				<option value="村集体组织">村集体组织</option>
				<option value="农民专业合作社">农民专业合作社</option>
				<option value="高校">高校</option>
				<option value="旅游饮食">旅游饮食</option>
				</select>
				<button id="set_acc_category">点击提交</button>
			  </fieldset>
			</form>
		</div>
		<div id="for_debug" />
    </body>
</html>